package com.atguigu.gulimall.product.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;

import com.atguigu.gulimall.product.dao.MusersDao;
import com.atguigu.gulimall.product.entity.MusersEntity;
import com.atguigu.gulimall.product.service.MusersService;
import org.springframework.util.StringUtils;


@Service("musersService")
public class MusersServiceImpl extends ServiceImpl<MusersDao, MusersEntity> implements MusersService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        QueryWrapper<MusersEntity> musersEntityQueryWrapper = new QueryWrapper<MusersEntity>();
        if(!StringUtils.isEmpty(key)){
            musersEntityQueryWrapper.eq("user_id",key).or().like("userName",key);
        }
        IPage<MusersEntity> page = this.page(
                new Query<MusersEntity>().getPage(params),musersEntityQueryWrapper

        );

        return new PageUtils(page);
    }

}